package com.atxwq.shop.manager.serivce.impl;

import com.atxwq.shop.manager.mapper.CategoryBrandMapper;
import com.atxwq.shop.manager.serivce.CategoryBrandService;
import com.atxwq.shop.model.dto.product.CategoryBrandDto;
import com.atxwq.shop.model.entity.product.Brand;
import com.atxwq.shop.model.entity.product.CategoryBrand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description 分类品牌管理服务层实现类
 * @Date 2025/5/13 16:41
 * @Created by 12336
 */
@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {

    @Autowired
    private CategoryBrandMapper categoryBrandMapper;

    /**
     * 分页+搜索查询分类品牌
     * @param page
     * @param limit
     * @param categoryBrandDto
     * @return
     */
    @Override
    public PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto) {
        PageHelper.startPage(page, limit);
        List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(categoryBrandDto);
        return new PageInfo<>(categoryBrandList);
    }

    /**
     * 添加品牌分类
     * @param categoryBrand
     */
    @Override
    public void save(CategoryBrand categoryBrand) {
        categoryBrandMapper.save(categoryBrand);
    }

    /**
     * 修改品牌分类
     * @param categoryBrand
     */
    @Override
    public void update(CategoryBrand categoryBrand) {
        categoryBrandMapper.update(categoryBrand);
    }

    /**
     * 删除品牌分类
     * @param id
     */
    @Override
    public void delete(Long id) {
        categoryBrandMapper.delete(id);
    }

    /**
     * 查询商品品牌
     * @param categoryId
     * @return
     */
    @Override
    public List<Brand> findById(Long categoryId) {
        return categoryBrandMapper.findById(categoryId);
    }
}
